package vip.xiaonuo.supplier.modular.custom.customtag.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.supplier.modular.custom.customtag.entity.SupplierCustomTag;
import vip.xiaonuo.supplier.modular.custom.customtag.param.SupplierCustomTagAddParam;
import vip.xiaonuo.supplier.modular.custom.customtag.param.SupplierCustomTagEditParam;
import vip.xiaonuo.supplier.modular.custom.customtag.param.SupplierCustomTagIdParam;
import vip.xiaonuo.supplier.modular.custom.customtag.param.SupplierCustomTagPageParam;
import vip.xiaonuo.supplier.modular.custom.customtag.service.SupplierCustomTagService;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 客户标签控制器
 *
 * @author Mr.wu
 * @date  2025/03/15 17:55
 */
@Tag(name = "客户标签控制器")
@RestController
@Validated
public class SupplierCustomTagController {

    @Resource
    private SupplierCustomTagService supplierCustomTagService;

    /**
     * 获取客户标签分页
     *
     * @author Mr.wu
     * @date  2025/03/15 17:55
     */
    @Operation(summary = "获取客户标签分页")
    @SaCheckPermission("/supplier/custom/customtag/page")
    @GetMapping("/supplier/custom/customtag/page")
    public CommonResult<Page<SupplierCustomTag>> page(SupplierCustomTagPageParam supplierCustomTagPageParam) {
        return CommonResult.data(supplierCustomTagService.page(supplierCustomTagPageParam));
    }

    /**
     * 添加客户标签
     *
     * @author Mr.wu
     * @date  2025/03/15 17:55
     */
    @Operation(summary = "添加客户标签")
    @CommonLog("添加客户标签")
    @SaCheckPermission("/supplier/custom/customtag/add")
    @PostMapping("/supplier/custom/customtag/add")
    public CommonResult<String> add(@RequestBody @Valid SupplierCustomTagAddParam supplierCustomTagAddParam) {
        supplierCustomTagService.add(supplierCustomTagAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑客户标签
     *
     * @author Mr.wu
     * @date  2025/03/15 17:55
     */
    @Operation(summary = "编辑客户标签")
    @CommonLog("编辑客户标签")
    @SaCheckPermission("/supplier/custom/customtag/edit")
    @PostMapping("/supplier/custom/customtag/edit")
    public CommonResult<String> edit(@RequestBody @Valid SupplierCustomTagEditParam supplierCustomTagEditParam) {
        supplierCustomTagService.edit(supplierCustomTagEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除客户标签
     *
     * @author Mr.wu
     * @date  2025/03/15 17:55
     */
    @Operation(summary = "删除客户标签")
    @CommonLog("删除客户标签")
    @SaCheckPermission("/supplier/custom/customtag/delete")
    @PostMapping("/supplier/custom/customtag/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   List<SupplierCustomTagIdParam> supplierCustomTagIdParamList) {
        supplierCustomTagService.delete(supplierCustomTagIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取客户标签详情
     *
     * @author Mr.wu
     * @date  2025/03/15 17:55
     */
    @Operation(summary = "获取客户标签详情")
    @SaCheckPermission("/supplier/custom/customtag/detail")
    @GetMapping("/supplier/custom/customtag/detail")
    public CommonResult<SupplierCustomTag> detail(@Valid SupplierCustomTagIdParam supplierCustomTagIdParam) {
        return CommonResult.data(supplierCustomTagService.detail(supplierCustomTagIdParam));
    }
}
